// Copyright (C) 2023 即时通讯网(52im.net) & Jack Jiang.
// The RainbowChat Project. All rights reserved.
// 
// 【本产品为著作权产品，合法授权后请放心使用，禁止外传！】
// 【本次授权给：<北京小羊驼科技有限公司>，授权编号：<NT231212144350>，代码指纹：<A.702363430.550>，技术对接人微信：<ID: wxid_wbyootvkdcgj22>】
// 【授权寄送：<收件：苏先生、地址：北京市大兴区北京密码西区6号楼1单元301、电话：18613885610、邮箱：bd@huiyuanxiang-inc.com>】
// 
// 【本系列产品在国家版权局的著作权登记信息如下】：
// 1）国家版权局登记名(简称)和权证号：RainbowChat    （证书号：软著登字第1220494号、登记号：2016SR041877）
// 2）国家版权局登记名(简称)和权证号：RainbowChat-Web（证书号：软著登字第3743440号、登记号：2019SR0322683）
// 3）国家版权局登记名(简称)和权证号：RainbowAV      （证书号：软著登字第2262004号、登记号：2017SR676720）
// 4）国家版权局登记名(简称)和权证号：MobileIMSDK-Web（证书号：软著登字第2262073号、登记号：2017SR676789）
// 5）国家版权局登记名(简称)和权证号：MobileIMSDK    （证书号：软著登字第1220581号、登记号：2016SR041964）
// * 著作权所有人：江顺/苏州网际时代信息科技有限公司
// 
// 【违法或违规使用投诉和举报方式】：
// 联系邮件：jack.jiang@52im.net
// 联系微信：hellojackjiang
// 联系QQ号：413980957
// 授权说明：http://www.52im.net/thread-1115-1-1.html
// 官方社区：http://www.52im.net
package com.x52im.rbchat.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.eva.android.shortvideo.ShortVideoRecordActivity;
import com.eva.android.widget.ImageViewActivity.ImageDataType;
import com.x52im.rbchat.Const;
import com.x52im.rbchat.MyApplication;
import com.x52im.rainbowchat.http.logic.dto.GroupEntity;
import com.x52im.rainbowchat.http.logic.dto.RosterElementEntity;
import com.x52im.rainbowchat.http.logic.dto.UserRegisterDTO;
import com.x52im.rbchat.logic.chat_friend.FriendChattingActivity;
import com.x52im.rbchat.logic.chat_friend.gift.GiftsHistoryActivity;
import com.x52im.rbchat.logic.chat_friend.vv.VideoCallComeActivity;
import com.x52im.rbchat.logic.chat_friend.vv.VideoCallOutActivity;
import com.x52im.rbchat.logic.chat_group.GroupChattingActivity;
import com.x52im.rbchat.logic.chat_guest.TempChattingActivity;
import com.x52im.rbchat.logic.chat_root.targetchoose.TargetChooseActivity;
import com.x52im.rbchat.logic.chat_root.model.LocationMeta;
import com.x52im.rbchat.logic.chat_root.sendfile.BigFileViewerActivity;
import com.x52im.rbchat.logic.chat_root.sendimg.PreviewAndSendActivity;
import com.x52im.rbchat.logic.chat_root.sendlocation.GetLocationActivity;
import com.x52im.rbchat.logic.chat_root.sendlocation.ViewLocationActivity;
import com.x52im.rbchat.logic.chat_root.sendshortvideo.ReceivedShortVideoHelper;
import com.x52im.rbchat.logic.chat_root.targetchoose.TargetSourceFilter4Friend;
import com.x52im.rbchat.logic.chat_root.targetchoose.TargetSourceFilter4Group;
import com.x52im.rbchat.logic.chat_root.targetchoose.TargetSourceFilter4LatestChatting;
import com.x52im.rbchat.logic.main.LoginActivity;
import com.x52im.rbchat.logic.main.MainActivity;
import com.eva.android.widget.CommonWebActivity2;
import com.x52im.rbchat.logic.more.HelpActivity;
import com.x52im.rbchat.logic.profile.photo.PhotosViewActivity;
import com.x52im.rbchat.logic.profile.photo.PreviewAndUploadActivity;
import com.x52im.rbchat.logic.profile.photo.ViewPhotoActivity;
import com.x52im.rbchat.logic.profile.voice.PVoiceViewActivity;
import com.x52im.rbchat.logic.qrcode.QRCodeGenerateActivity;
import com.x52im.rbchat.logic.qrcode.QRCodeScanActivity;
import com.x52im.rbchat.logic.qrcode.utils.QRCodeScheme;
import com.x52im.rbchat.logic.register.ForgetPassWordActivity;
import com.x52im.rbchat.logic.register.RegisterActivity;
import com.x52im.rbchat.logic.register.RegisterSuccessActivity;
import com.x52im.rbchat.logic.sns_friend.ChatInfoActivity;
import com.x52im.rbchat.logic.sns_friend.FindFriendFormActivity;
import com.x52im.rbchat.logic.sns_friend.FindFriendResultActivity2;
import com.x52im.rbchat.logic.sns_friend.FriendInfoActivity;
import com.x52im.rbchat.logic.sns_friend.FriendRemarkEditActivity;
import com.x52im.rbchat.logic.sns_friend.FriendReqProcessActivity;
import com.x52im.rbchat.logic.sns_friend.InviteFriendActivity;
import com.x52im.rbchat.logic.sns_friend.FriendsReqListActivity;
import com.x52im.rbchat.logic.sns_group.GroupInfoActivity;
import com.x52im.rbchat.logic.sns_group.GroupMemberActivity;
import com.x52im.rbchat.logic.sns_group.GroupsActivity;
import com.x52im.rbchat.logic.sns_group.JoinGroupActivity;

import java.io.Serializable;
import java.util.ArrayList;

public class IntentFactory
{
	/**
	 * 打开SceneMgrActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param photoOfUid 本参数是必须的，表示查看/管理的是谁的语音
	 * @param canMgr 本参数是必须的，true表示是否有上传、删除等功能
	 * (通常是本地用户查看自已的语音时)，否则表示仅用查看权限（而无法上
	 * 传、删除等）通常用于查看别人的语音时
	 * @return
	 */
	public static Intent createPVoiceViewActivityIntent(Context thisActivity
			, String photoOfUid, boolean canMgr)
	{
		Intent intent = new Intent(thisActivity, PVoiceViewActivity.class);
		intent.putExtra("__photoOfUid__", photoOfUid);
		intent.putExtra("__canMgr__", canMgr);
		return intent;
	}
	/**
	 * 解析intent传过来给SceneMgrActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parsePVoiceViewActivityIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getStringExtra("__photoOfUid__"));
		datas.add(intent.getBooleanExtra("__canMgr__", false));
		return datas;
	}
	
	/**
	 * 打开ViewPhotoActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param imageDataType 必需参数：要查看的图看资源来源类型，参见类{@link ImageDataType}
	 * @param imageDataSrc 必需参数：资源来源
	 * @param saveToDir 可选参数：当imageDataType={@link ImageDataType#URL}时此参数为必须，表示图片缓存path
	 * @param canMgr 必需参数：存发送图片功能的应用场景参数: 0 表示仅用于查看、1 表示可
	 * 查看且可以删除之（通常由相片所有者使用），详见{@link ViewPhotoActivity}
	 * @param photoId 可选参数：放于服务端的对应db记录主键id，当canMgr="true"时，本参数为必需，否则可为null
	 * @param fileName 可选参数：存放于服务端磁盘上的文件名，当canMgr="true"时，本参数为必需，否则可为null
	 * @return
	 */
	public static Intent createViewPhotoActivityIntent(Context thisActivity
			, int imageDataType, String imageDataSrc, String saveToDir
			, boolean canMgr, String photoId, String fileName)
	{
		return com.eva.android.IntentFactory.createImageViewActivityIntent(thisActivity, imageDataType, imageDataSrc, ViewPhotoActivity.class
				, -1, -1
				, saveToDir 		// exData1
				, canMgr?"1":"0"    // exData2
				, photoId   		// exData3
				, fileName  		// exData4
				, null, null);
	}
	
	/**
	 * 打开PreviewAndSendActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param imageDataType
	 * @param imageDataSrc
	 * @return
	 */
	public static Intent createPreviewAndUploadActivityIntent(Context thisActivity
			, int imageDataType, String imageDataSrc, String friendUID)
	{
		return com.eva.android.IntentFactory.createImageViewActivityIntent(thisActivity, imageDataType, imageDataSrc, PreviewAndUploadActivity.class
				, -1, -1
				, friendUID
				, null
				, null, null, null, null);
	}
	
	/**
	 * 打开SceneMgrActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param photoOfUid 本参数是必须的，表示查看/管理的是谁的相册
	 * @param canMgr 本参数是必须的，true表示是否有上传、删除等功能
	 * (通常是本地用户查看自已的相册时)，否则表示仅用查看权限（而无法上
	 * 传、删除等）通常用于查看别人的相册时
	 * @return
	 */
	public static Intent createPhotosViewActivityIntent(Context thisActivity
			, String photoOfUid, boolean canMgr)
	{
		Intent intent = new Intent(thisActivity, PhotosViewActivity.class);
		intent.putExtra("__photoOfUid__", photoOfUid);
		intent.putExtra("__canMgr__", canMgr);
		return intent;
	}
	/**
	 * 解析intent传过来给SceneMgrActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parsePhotosViewActivityIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getStringExtra("__photoOfUid__"));
		datas.add(intent.getBooleanExtra("__canMgr__", false));
		return datas;
	}
	
	/**
	 * 打开VerificationRemindersActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createVerificationRemindersActivityIntent(Context thisActivity)
	{
		Intent intent = new Intent(thisActivity, FriendsReqListActivity.class);
		return intent;
	}
	
	/**
	 * 打开PreviewAndSendActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param imageDataType
	 * @param imageDataSrc
	 * @param usedFor 发送图片功能的应用场景参数，详见{@link Const}
	 * @return
	 * @see Const#CHAT_TYPE_FREIDN$CHAT
	 * @see Const#CHAT_TYPE_GUEST$CHAT
	 * @see Const#CHAT_TYPE_GROUP$CHAT
	 */
	public static Intent createPreviewAndSendActivityIntent(Context thisActivity
			, int imageDataType, String imageDataSrc, String friendUID, String usedFor)
	{
		return com.eva.android.IntentFactory.createImageViewActivityIntent(thisActivity
				, imageDataType
				, imageDataSrc
				, PreviewAndSendActivity.class
				, -1, -1
				, friendUID
				, usedFor
				, null, null, null, null);
	}
	
	/**
	 * 打开VideoCallComeActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createHelpActivityIntent(Context thisActivity
			, int finishAction, boolean isJiaocheng)
	{
		Intent intent = new Intent(thisActivity, HelpActivity.class);
		intent.putExtra("finish_action", finishAction);
		intent.putExtra("isJiaocheng", isJiaocheng);
		return intent;
	}
	/**
	 * 解析intent传过来给VideoCallComeActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parseHelpActivityIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getIntExtra("finish_action", -1));
		datas.add(intent.getBooleanExtra("isJiaocheng", false));
		return datas;
	}
	

	/**
	 * 打开ForgetPassWordActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createForgetPassWordIntent(Context thisActivity)
	{
		Intent intent = new Intent(thisActivity, ForgetPassWordActivity.class);
		return intent;
	}

	// -------------------------------------------------------------------------------------------
	// for new VV S
	/**
	 * 打开VideoCallComeActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param friendUIDForInit
	 * @return
	 */
	public static Intent createVideoCallComeIntent(Context thisActivity, String friendUIDForInit)
	{
		Intent intent = new Intent(thisActivity, VideoCallComeActivity.class);
		if (friendUIDForInit != null)
			intent.putExtra("__friendUIDForInit__", friendUIDForInit);
		return intent;
	}

	/**
	 * 解析intent传过来给VideoCallComeActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static String parseVideoCallComeIntent(Intent intent)
	{
		return intent.getStringExtra("__friendUIDForInit__");
	}

	/**
	 * 打开VideoCallOutActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @param friendUIDForInit
	 * @return
	 */
	public static Intent createVideoCallOutIntent(Context thisActivity, String friendUIDForInit)
	{
		Intent intent = new Intent(thisActivity, VideoCallOutActivity.class);
		if (friendUIDForInit != null)
			intent.putExtra("__friendUIDForInit__", friendUIDForInit);
		return intent;
	}

	/**
	 * 解析intent传过来给VideoCallOutActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static String parseVideoCallOutIntent(Intent intent)
	{
		return intent.getStringExtra("__friendUIDForInit__");
	}

	/**
	 * 解析intent传过来给SceneMgrActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static String parseSceneMgrIntent(Intent intent)
	{
		return intent.getStringExtra("__myCurrentSenceName__");
	}

	/**
	 * 打开PortalActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createPortalIntent(Context thisActivity)
	{
		Intent intent = new Intent(thisActivity, MainActivity.class);
		// add by JackJiang 20180117：为了切换账号时保证一个干净的activity栈逻辑
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return intent;
	}

	/**
	 * 打开FriendReqProcessActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createFriendReqProcessIntent(Context thisActivity, RosterElementEntity friendInfo)
	{
		Intent intent = new Intent(thisActivity, FriendReqProcessActivity.class);
		intent.putExtra("__friendInfo__", friendInfo);
//		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		
		// 为此Flag时：将保证从Notification点进来时，无论从FriendReqProcessActivity界面点进到了多少个界面都将可以保证
		// 再次打开FriendReqProcessActivity时都将将之前从此界面打开并进入的界面都清除掉，使得每次点进这个界面后如果再back
		// 时就直接回到这个界面首次被打开时的最初状态，否则back时将通多少层activity？这显然就不对了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		
		return intent;
	}

	/**
	 * 解析intent传过来给FriendReqProcessActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parseFriendReqProcessIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__friendInfo__"));
		return datas;
	}
	
	/**
	 * 打开群聊/世界频道界面。
     *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createGroupChatIntent(Context thisActivity, String gid, String gname)
	{
		Intent intent = new Intent(thisActivity, GroupChattingActivity.class);
        intent.putExtra("__gid__", gid);
        intent.putExtra("__gname__", gname);
		
		// 为此Flag时：将保证从Notification点进来时，无论从FriendReqProcessActivity界面
		// 点进到了多少个界面都将可以保证再次打开FriendReqProcessActivity时都将将之前从此
		// 界面打开并进入的界面都清除掉，使得每次点进这个界面后如果再back时就直接回到这个界
		// 面首次被打开时的最初状态，否则back时将通多少层activity？这显然就不对了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return intent;
	}

    /**
     * 解析intent传过来给群聊/世界频道的数据。
     *
     * @param intent
     * @return
     */
    public static ArrayList parseBBSChatIntent(Intent intent)
    {
        ArrayList datas = new ArrayList();
        datas.add(intent.getSerializableExtra("__gid__"));
        datas.add(intent.getSerializableExtra("__gname__"));
        return datas;
    }

	/**
	 * 进入一对一陌生人/临时聊天界面.
     *
	 * @param thisActivity
	 * @param fromUserUid
	 * @param fromUserNickName
	 * @return
	 */
	public static Intent createTempChatIntent(Context thisActivity
			, String fromUserUid, String fromUserNickName
//			, String fromUserMail
	)
	{
		return createTempChatIntent(thisActivity, fromUserUid, fromUserNickName
//				, fromUserMail
				, 0);
	}
	/**
	 * 进入一对一陌生人/临时聊天界面
	 * 
	 * @param thisActivity
	 * @param fromUserUid
	 * @param fromUserNickName
	 * @param maxFriend 当<=0时，数据解析者将忽略本参数（表示无效）
	 * @return
	 */
	public static Intent createTempChatIntent(Context thisActivity
			, String fromUserUid, String fromUserNickName
//			, String fromUserMail
			, int maxFriend)
	{
		Intent intent = new Intent(thisActivity, TempChattingActivity.class);
		intent.putExtra("__fromUserUid__", fromUserUid);
		intent.putExtra("__fromUserNickName__", fromUserNickName);
//		intent.putExtra("__fromUserMail__", fromUserMail);
		intent.putExtra("__maxFriend__", maxFriend);
		
		// 为此Flag时：将保证从Notification点进来时，无论从FriendReqProcessActivity界面
		// 点进到了多少个界面都将可以保证再次打开FriendReqProcessActivity时都将将之前从此
		// 界面打开并进入的界面都清除掉，使得每次点进这个界面后如果再back时就直接回到这个界
		// 面首次被打开时的最初状态，否则back时将通多少层activity？这显然就不对了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return intent;
	}
	public static ArrayList parseTempChatIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__fromUserUid__"));
		datas.add(intent.getSerializableExtra("__fromUserNickName__"));
//		datas.add(intent.getSerializableExtra("__fromUserMail__"));
		datas.add(intent.getIntExtra("__maxFriend__", 0));
		return datas;
	}

	/**
	 * 打开FriendInfoFormActivity的Intent构造方法.
	 * 此方法目前用于注册成功后，自动把登陆名和密码传入登陆界面从而方便登陆的场景.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createFriendInfoIntent(Context thisActivity, RosterElementEntity friendInfo
//			, boolean usedForShow
			)
	{
		Intent intent = new Intent(thisActivity, FriendInfoActivity.class);
		intent.putExtra("__friendInfo__", friendInfo);
//		intent.putExtra("__usedForShow__", usedForShow);
//		// intent.putExtra("__isOnline__", isOnline);
		
		// 为此Flag时：将保证从Notification点进来时，无论从FriendReqProcessActivity界面
		// 点进到了多少个界面都将可以保证再次打开FriendReqProcessActivity时都将将之前从此
		// 界面打开并进入的界面都清除掉，使得每次点进这个界面后如果再back时就直接回到这个界
		// 面首次被打开时的最初状态，否则back时将通多少层activity？这显然就不对了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return intent;
	}
	/**
	 * 解析intent传过来给FriendInfoFormActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parseFriendInfoIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__friendInfo__"));
//		datas.add(intent.getSerializableExtra("__usedForShow__"));
//		// datas.add(intent.getSerializableExtra("__isOnline__"));
		return datas;
	}

	/**
	 * 打开FindFriendResultActivity2的Intent构造方法.
	 *
	 * @param thisActivity
	 * @param onlineStatus -1 - 表示不区分是否在线，1 - 表示只查在线，0 - 表示只查离线
	 * @param male -1 - 表示不区分性别，1  - 表示只查男性，0 - 表示只查女性
	 * @return
	 */
	public static Intent createFriendInfoListIntent(Activity thisActivity
//			, ArrayList<RosterElementEntity> friendInfo
//			, Object[] toServer
			, String onlineStatus, String male
			)
	{
//		Intent intent = new Intent(thisActivity, FindFriendResultActivity.class);
		Intent intent = new Intent(thisActivity, FindFriendResultActivity2.class);
		intent.putExtra("__onlineStatus__", onlineStatus);
		intent.putExtra("__male__", male);
		return intent;
	}
	public static ArrayList parseFriendInfoListIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__onlineStatus__"));
		datas.add(intent.getSerializableExtra("__male__"));
		return datas;
	}

	/**
	 * 打开FindFriendFormActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createFindFriendIntent(Activity thisActivity)
	{
		Intent intent = new Intent(thisActivity, FindFriendFormActivity.class);
		return intent;
	}

	/**
	 * 打开InviteFriendFormActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createInviteFriendIntent(Activity thisActivity)
	{
		Intent intent = new Intent(thisActivity, InviteFriendActivity.class);
		return intent;
	}

	/**
	 * 打开InviteFriendFormActivity的Intent构造方法.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createInviteFriendIntent(Activity thisActivity, String sendToMail)
	{
		Intent intent = new Intent(thisActivity, InviteFriendActivity.class);
		intent.putExtra("__sendToMail__", sendToMail);
		return intent;
	}

	/**
	 * 解析intent传过来给InviteFriendFormActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static String parseInviteFriendIntent(Intent intent)
	{
		return intent.getStringExtra("__sendToMail__");
	}

	public static Intent createChatIntent(Context thisActivity, String friendUID)
	{
		return createChatIntent(thisActivity, friendUID, false, 0);
	}
	/**
	 * 打开ChatActivity的Intent构造方法. 此方法通常用于无法普通地打开登陆界面的场景.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createChatIntent(Context thisActivity, String friendUID
			, boolean startupRealTimeVoiceBeCallingForInit, long startupRealTimeVoiceBeCallingTimeForInit)
	{
		Intent intent = new Intent(thisActivity, FriendChattingActivity.class);
		intent.putExtra("__selected$friend__", friendUID);
		intent.putExtra("__startupRealTimeVoiceBeCallingForInit__", startupRealTimeVoiceBeCallingForInit);
		intent.putExtra("__startupRealTimeVoiceBeCallingTimeForInit__", startupRealTimeVoiceBeCallingTimeForInit);
		
		// 为此Flag时：将保证从Notification点进来时，无论从FriendReqProcessActivity界面
		// 点进到了多少个界面都将可以保证再次打开FriendReqProcessActivity时都将将之前从此
		// 界面打开并进入的界面都清除掉，使得每次点进这个界面后如果再back时就直接回到这个界
		// 面首次被打开时的最初状态，否则back时将通多少层activity？这显然就不对了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		
		return intent;
	}
	/**
	 * 解析intent传过来给ChatActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parseChatIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__selected$friend__"));
		datas.add(intent.getBooleanExtra("__startupRealTimeVoiceBeCallingForInit__", false));
		datas.add(intent.getLongExtra("__startupRealTimeVoiceBeCallingTimeForInit__", 0));
		return datas;
	}

	/**
	 * 打开RegisterActivity的Intent构造方法. 此方法通常用于无法普通地打开登陆界面的场景.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createRegisterIntent(Activity thisActivity)
	{
		Intent intent = new Intent(thisActivity, RegisterActivity.class);
		return intent;
	}

	/**
	 * 打开RegisterSuccess的Intent构造方法
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createRegisterSuccessIntent(Activity thisActivity, UserRegisterDTO u)
	{
		Intent intent = new Intent(thisActivity, RegisterSuccessActivity.class);
		intent.putExtra("__UserRegisterDTO__", u);
		return intent;
	}

	/**
	 * 解析intent传过来的RegisterActivity数据
	 * 
	 * @param intent
	 * @return
	 */
	public static UserRegisterDTO parseRegisterSuccessIntent(Intent intent)
	{
		return (UserRegisterDTO) intent.getSerializableExtra("__UserRegisterDTO__");
	}

	/**
	 * 打开LoginActivity的Intent构造方法. 此方法通常用于无法普通地打开登陆界面的场景.
	 * 
	 * @param thisActivity
	 * @return
	 */
	public static Intent createLoginIntent(Context thisActivity)
	{
		// init MobileIMSDK first（必须保证此代码被调用，否则IM框架无法完成IM服务器的连接等工作）
		// 通常在打开登陆界面调用此方法，是合理的，因为它下一步就是登陆im框架啊
	    MyApplication.getInstance(thisActivity).getIMClientManager().initMobileIMSDK();
	    
		Intent intent = new Intent(thisActivity, LoginActivity.class);
		return intent;
	}

	/**
	 * 打开LoginActivity的Intent构造方法. 此方法目前用于注册成功后，自动把登陆名和密码传入登陆界面从而方便登陆的场景.
	 * 
	 * @param thisActivity
	 * @param loginUidOrEmail
	 * @param loginPassword
	 * @return
	 */
	public static Intent createLoginIntent(Activity thisActivity, String loginUidOrEmail, String loginPassword)
	{
		Intent intent = new Intent(thisActivity, LoginActivity.class);
		intent.putExtra("__loginUidOrEmail__", loginUidOrEmail);
		intent.putExtra("__loginPassword__", loginPassword);

		return intent;
	}
	/**
	 * 解析intent传过来给LoginActivity的数据.
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parseLoginFormIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__loginUidOrEmail__"));
		datas.add(intent.getSerializableExtra("__loginPassword__"));
		return datas;
	}

//	public static Intent createFindListFormIntent(Activity thisActivity, ArrayList<RosterElementEntity> rosterList)
//	{
//		Intent intent = new Intent(thisActivity, FindFriendResultActivity.class);
//		intent.putExtra("__rosterList__", rosterList);
//
//		return intent;
//	}
	
	/**
	 * 通用WebActivity
	 * @param thisActivity
	 * @param url
	 * @return
	 */
//	public static Intent createCommonWebActivityIntent(Activity thisActivity, String url)
//	{
//		Intent intent = new Intent(thisActivity, CommonWebActivity.class);
//		intent.putExtra("__url__", url);
//		return intent;
//	}
////	/**
////	 * 打开淘宝手机WEB版的Activity.
////	 *
////	 * @param thisActivity
////	 * @return
////	 */
////	public static Intent createTaobaoWebActivityIntent(Activity thisActivity)
////	{
////		Intent intent = new Intent(thisActivity, TaobaoWebCNActivity.class);
////		intent.putExtra("__url__", MyApplication.CN_MALL_MAIN_URL);
////		return intent;
////	}
//	public static String parseCommonWebIntent(Intent intent)
//	{
//		return intent.getStringExtra("__url__");
//	}

	/**
	 * 通用WebActivity2
	 * @param thisActivity
	 * @param url
	 * @return
	 */
	public static Intent createCommonWebActivity2Intent(Activity thisActivity, String url, String title, boolean forSafe)
	{
		Intent intent = new Intent(thisActivity, CommonWebActivity2.class);
		intent.putExtra("__url__", url);
		intent.putExtra("__title__", title);
		intent.putExtra("__for_safe__", forSafe);
		return intent;
	}
	public static ArrayList parseCommonWeb2Intent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__url__"));
		datas.add(intent.getSerializableExtra("__title__"));
		datas.add(intent.getSerializableExtra("__for_safe__"));
		return datas;
	}
	
	public static Intent createGiftHistoryIntent(Activity thisActivity, String localUid, String gifIdent)
	{
		Intent intent = new Intent(thisActivity, GiftsHistoryActivity.class);
		intent.putExtra("__local_uid__", localUid);
		intent.putExtra("__gift_ident__", gifIdent);

		return intent;
	}
	/**
	 * 
	 * @param intent
	 * @return
	 */
	public static ArrayList parseGiftHistoryIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getStringExtra("__local_uid__"));
		datas.add(intent.getStringExtra("__gift_ident__"));
		return datas;
	}


	/**
	 * 打开查看大文件的Intent构造方法.

	 * @return
	 */
	public static Intent createBigFileViewerIntent(Context thisActivity, 
												   String fileName,
												   String fileDir,
												   String fileMd5,
												   long fileLength,
												   boolean canDownload)
	{
		Intent intent = new Intent(thisActivity, BigFileViewerActivity.class);
		intent.putExtra("__fileName__", fileName);
		intent.putExtra("__fileDir__", fileDir);
		intent.putExtra("__fileMd5__", fileMd5);
		intent.putExtra("__fileLength__", fileLength);
		intent.putExtra("__canDownload__", canDownload);

		return intent;
	}
	/**
	 * 解析intent传过来给BigFileViewerActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList parseBigFileViewerIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__fileName__"));
		datas.add(intent.getSerializableExtra("__fileDir__"));
		datas.add(intent.getSerializableExtra("__fileMd5__"));
		datas.add(intent.getLongExtra("__fileLength__", 0));
		datas.add(intent.getBooleanExtra("__canDownload__", false));
		return datas;
	}

	/**
	 * 打开GroupMemberActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @param usedFor @see {@link GroupMemberActivity}
	 * @param gid 本参数在创建群时，只需传null即可
	 * @param defaultSelectedUid 本参数在创建群时，表示默认要选中的uid（可为null），其它情况目前请填null
	 * @return
	 */
	public static Intent createGroupMemberActivityIntent(Context thisActivity
			, int usedFor, String gid, boolean isGroupOwner, String defaultSelectedUid)
	{
		Intent intent = new Intent(thisActivity, GroupMemberActivity.class);
		intent.putExtra("__usedFor__", usedFor);
		intent.putExtra("__gid__", gid);
		intent.putExtra("__isGroupOwner__", isGroupOwner);
		intent.putExtra("__defaultSelectedUid__", defaultSelectedUid);
		return intent;
	}
	/**
	 * 解析intent传过来给GroupMemberActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList<Object> parseGroupMemberActivityIntent(Intent intent)
	{
		ArrayList<Object> datas = new ArrayList<>();
		datas.add(intent.getIntExtra("__usedFor__", -1));
		datas.add(intent.getStringExtra("__gid__"));
		datas.add(intent.getBooleanExtra("__isGroupOwner__", false));
		datas.add(intent.getStringExtra("__defaultSelectedUid__"));
		return datas;
	}

	/**
	 * 打开GroupInfoActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createGroupInfoIntent(Context thisActivity, GroupEntity groupInfo)
	{
		Intent intent = new Intent(thisActivity, GroupInfoActivity.class);
		intent.putExtra("__groupInfo__", groupInfo);
		return intent;
	}
	/**
	 * 解析intent传过来给GroupInfoActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList parseGroupInfoIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__groupInfo__"));
		return datas;
	}

	/**
	 * 打开GroupsActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createGroupsIntent(Context thisActivity, boolean goHomeOnBackPressed)
	{
		Intent intent = new Intent(thisActivity, GroupsActivity.class);
		intent.putExtra("__goHomeOnBackPressed__", goHomeOnBackPressed);
		return intent;
	}
	/**
	 * 解析intent传过来给GroupsActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList parseGroupsIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getBooleanExtra("__goHomeOnBackPressed__", true));
		return datas;
	}

    /**
     * 打开ShortVideoRecordActivity的Intent构造方法.
     *
     * @param thisActivity
     * (通常是本地用户查看自已的语音时)，否则表示仅用查看权限（而无法上
     * 传、删除等）通常用于查看别人的语音时
     * @return
     */
    public static Intent createShortVideoRecordActivityIntent(Context thisActivity)
    {
        Intent intent = new Intent(thisActivity, ShortVideoRecordActivity.class);
        intent.putExtra("__saveDir__", ReceivedShortVideoHelper.getReceivedShortVideoSavedDirHasSlash());
        return intent;
    }

	/**
	 * 打开UserChooseActivity的Intent构造方法.
	 *
	 * @param usedFor 本界面的业务用途（比如：用于什么功能）。@see {@link TargetChooseActivity#USED_FOR_SEND_CONTACT_MESSAGE}
	 * @param chatType 聊天类型（比如：用于一对一聊还是群聊中）。@see {@link Const#CHAT_TYPE_FREIDN$CHAT}
	 * @param toId 本界面选中的数据要发送给的目标id。注意：目前本字段仅用于 #usedForForInit==USED_FOR_SEND_CONTACT_MESSAGE
	 *               && chatType=好友或陌生人聊天时，其它情况下本参数无意义，可以填null！
	 * @return
	 */
	public static Intent createTargetChooseActivityIntent(Context thisActivity
														, int supportedTargetSource
														, TargetSourceFilter4LatestChatting targetSourceFilter4LatestChatting
														, TargetSourceFilter4Friend targetSourceFilter4Friend
														, TargetSourceFilter4Group targetSourceFilter4Group
														, Serializable extraObj)
	{
		Intent intent = new Intent(thisActivity, TargetChooseActivity.class);
//		intent.putExtra("__usedFor__", usedFor);
//		intent.putExtra("__chatType__", chatType);
//		intent.putExtra("__toId__", toId);

		intent.putExtra("__supportedTargetSource__", supportedTargetSource);
		if(targetSourceFilter4LatestChatting != null){
			intent.putExtra("__targetSourceFilterLatestChatting__", targetSourceFilter4LatestChatting);
		}
		if(targetSourceFilter4Friend != null){
			intent.putExtra("__targetSourceFilterFriend__", targetSourceFilter4Friend);
		}
		if(targetSourceFilter4Group != null){
			intent.putExtra("__targetSourceFilterGroup__", targetSourceFilter4Group);
		}
		if(extraObj != null) {
			intent.putExtra("__extraObj__", extraObj);
		}

		return intent;
	}
	/**
	 * 解析intent传过来给UserChooseActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList parseTargetChooseActivityIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
//		datas.add(intent.getIntExtra("__usedFor__", -1));
//		datas.add(intent.getStringExtra("__chatType__"));
//		datas.add(intent.getStringExtra("__toId__"));

		datas.add(intent.getIntExtra("__supportedTargetSource__", -1));
		datas.add(intent.getSerializableExtra("__targetSourceFilterLatestChatting__"));
		datas.add(intent.getSerializableExtra("__targetSourceFilterFriend__"));
		datas.add(intent.getSerializableExtra("__targetSourceFilterGroup__"));
		datas.add(intent.getSerializableExtra("__extraObj__"));

		return datas;
	}

	/**
	 * 打开GetLocationActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createGetLocationActivityIntent(Activity thisActivity)
	{
		Intent intent = new Intent(thisActivity, GetLocationActivity.class);
		return intent;
	}

	/**
	 * 打开ViewLocationActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createViewLocationActivityIntent(Context thisActivity, LocationMeta lm)
	{
		Intent intent = new Intent(thisActivity, ViewLocationActivity.class);
		intent.putExtra("__locationMeta__", lm);
		return intent;
	}
	/**
	 * 解析intent传过来给ViewLocationActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList parseViewLocationActivityIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__locationMeta__"));
		return datas;
	}

	/**
	 * 打开FriendRemarkEditActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createFriendRemarkEditIntent(Context thisActivity, String friendUid)
	{
		Intent intent = new Intent(thisActivity, FriendRemarkEditActivity.class);
		intent.putExtra("__friend_uid__", friendUid);
		return intent;
	}

	/**
	 * 解析intent传过来给FriendRemarkEditActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList parseFriendRemarkEditIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getSerializableExtra("__friend_uid__"));
		return datas;
	}

	/**
	 * 打开ChatInfoActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createChatInfoIntent(Context thisActivity, String uid, String nickname)
	{
		Intent intent = new Intent(thisActivity, ChatInfoActivity.class);
		intent.putExtra("__uid__", uid);
		intent.putExtra("__nickname__", nickname);
		return intent;
	}
	/**
	 * 解析intent传过来给GroupInfoActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList<String> parseChatInfoIntent(Intent intent)
	{
		ArrayList<String> datas = new ArrayList();
		datas.add(intent.getStringExtra("__uid__"));
		datas.add(intent.getStringExtra("__nickname__"));
		return datas;
	}

	/**
	 * 打开QRCodeScanActivity的Intent构造方法.
	 *
	 * @param thisActivity
	 * @return
	 */
	public static Intent createQRCodeScanIntent(Context thisActivity)
	{
		Intent intent = new Intent(thisActivity, QRCodeScanActivity.class);
		// 为此Flag时：将保证从此界面点进到了多少个子界面都将可以保证再次打开本界面时都将将之前从此界面打
		// 开并进入的界面都清除掉，使得每次点进这个界面后如果再back时就直接回到这个界面首次被打开时的最初状态，
		// 否则back时将通多少层activity？这显然就影响体验了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return intent;
	}

	/**
	 * 打开"我的二维码"界面的Intent构造方法.
	 *
	 * @param thisActivity activity上下文
	 * @return 返回intent对象
	 */
	public static Intent createQRCodeGenerateMyIntent(Context thisActivity)
	{
		RosterElementEntity localUserInfo = MyApplication.getInstance2().getIMClientManager().getLocalUserInfo();
		if(localUserInfo != null)
			return createQRCodeGenerateIntent(thisActivity, QRCodeScheme.QR_CODE_SCHEME_ADD_USER, localUserInfo.getUser_uid());
		return null;
	}

	/**
	 * 打开"群聊二维码"界面的Intent构造方法.
	 *
	 * @param thisActivity activity上下文
	 * @param gid 群id
	 * @return 返回intent对象
	 */
	public static Intent createQRCodeGenerateGroupIntent(Context thisActivity, String gid)
	{
		return createQRCodeGenerateIntent(thisActivity, QRCodeScheme.QR_CODE_PSCHEME_JOIN_GROUP, gid);
	}

	/**
	 * 打开QRCodeGenerateActivity的Intent构造方法.
	 *
	 *
	 * @param thisActivity activity上下文
	 * @param scheme 生成的2维码前缀，见{@link QRCodeScheme}
	 * @param id 生成2维码的id编号
	 * @return 返回intent对象
	 */
	public static Intent createQRCodeGenerateIntent(Context thisActivity, String scheme, String id)
	{
		Intent intent = new Intent(thisActivity, QRCodeGenerateActivity.class);
		intent.putExtra("__scheme__", scheme);
		intent.putExtra("__id__", id);

		// 为此Flag时：将保证从此界面点进到了多少个子界面都将可以保证再次打开本界面时都将将之前从此界面打
		// 开并进入的界面都清除掉，使得每次点进这个界面后如果再back时就直接回到这个界面首次被打开时的最初状态，
		// 否则back时将通多少层activity？这显然就影响体验了！
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return intent;
	}
	/**
	 * 解析intent传过来给QRCodeGenerateActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList<String> parseQRCodeGenerateIntent(Intent intent)
	{
		ArrayList<String> datas = new ArrayList();
		datas.add(intent.getStringExtra("__scheme__"));
		datas.add(intent.getStringExtra("__id__"));
		return datas;
	}

	/**
	 * 打开JoinGroupActivity的Intent构造方法.
	 *
	 *
	 * @param thisActivity activity上下文
	 * @param qrcodeValue 群id和其它信息（对应的是加群2维码数据内容部分）
	 * @param joinBy 加群类型，见 {@link JoinGroupActivity#JOIN_BY_SCAN_QRCODE}、 {@link JoinGroupActivity#JOIN_BY_GROUP_CONTACT}
	 * @return 返回intent对象
	 */
	public static Intent createJoinGroupIntent(Context thisActivity, String qrcodeValue, int joinBy)
	{
		Intent intent = new Intent(thisActivity, JoinGroupActivity.class);
		intent.putExtra("__qrv__", qrcodeValue);
		intent.putExtra("__join_by__", joinBy);
		return intent;
	}
	/**
	 * 解析intent传过来给JoinGroupActivity的数据.
	 *
	 * @param intent
	 * @return
	 */
	public static ArrayList<String> parseJoinGroupIntent(Intent intent)
	{
		ArrayList datas = new ArrayList();
		datas.add(intent.getStringExtra("__qrv__"));
		datas.add(intent.getIntExtra("__join_by__", JoinGroupActivity.JOIN_BY_SCAN_QRCODE));
		return datas;
	}
}
